unit b32hex;

interface

uses
  SysUtils;

type
  T32Byte = array [0..31] of byte;
  TKByte = array[0..1055] of Byte;
procedure App(var a1: T32Byte; var a2: TKByte);
procedure HexToVector(S: string; out Vec: T32Byte);
function VectorToHex(Vec: T32Byte): string;
implementation

procedure App(var a1: T32Byte; var a2: TKByte);
var
  i: Integer;
begin
  for i := 0 to 31 do
    a2[1024+i] := a1[i]

end;

procedure HexToVector(S: string; out Vec: T32Byte);
var
	i: integer;
  x: byte;
begin

  for i := 1 to Length( S ) do
  begin
    // Only process chunk of 2 digit Hexadecimal...
  	if ((i mod 2) = 1) then begin
      x := StrToInt( '0x' + Copy( S, i, 2 ));
	  	//Vec[i shr 1 - 1] := StrToInt( '0x' + Copy( S, i, 2 ));
      Vec[i shr 1] := x;
    end;
  end;
end;

function VectorToHex(Vec: T32Byte): string;
var
	i: integer;
begin
  Result := '';
  for i := 0 to 31 do
    Result := Result + IntToHex(Vec[i], 2)
  {SetLength(Result, 32);
  for i := 0 to 15 do
  begin

    Result[i shl 1] := IntToHex(Hi(Vec[i]), 1)[1];
    Result[i shl 1+1] := IntToHex(Lo(Vec[i]), 1)[1];
  end;}
end;

end.
